import { Component, ChangeDetectionStrategy, ViewEncapsulation, Optional } from '@angular/core'
import { AdTreeNodeProviderClass } from './tree.node.provider'

@Component({
  selector: 'ad-tree-node',
  template: ` <ad-tree-node-switcher
      [loading]="adTreeNodeProvider.adTreeData.loading"
      [expanded]="adTreeNodeProvider.adTreeData.expanded"
    ></ad-tree-node-switcher
    ><ng-content></ng-content>`,
  changeDetection: ChangeDetectionStrategy.OnPush,
  encapsulation: ViewEncapsulation.None,
  host: {
    '[class.ad-tree-node]': 'true',
    '[style.paddingLeft.px]': '(adTreeNodeProvider.adTreeData.level - 1) * 24',
  },
})
export class AdTreeNodeComponent {
  constructor(@Optional() public adTreeNodeProvider?: AdTreeNodeProviderClass) {}
}
